package com.tomorrow;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.http.client.OkHttp3ClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

/*@SpringBootApplication
@EnableDiscoveryClient //发现客户端注解，这里用于开启Eureka客户端，并将当前服务注册服务到服务中心
@EnableCircuitBreaker //开启hystrix熔断管理*/
@SpringCloudApplication // 内置上面三种注解
@EnableFeignClients //开启feignClient客户端优雅操作远程服务设置
public class ConsumerApplication {
    public static void main(String[] args) {
        SpringApplication.run(ConsumerApplication.class,args);
    }

    /*Feign自动集成了Ribbon负载均衡的RestTemplate客户端，所以不需要再进行注入
     * 开启Feign后需注解删除下面内容*/
    /*@Bean //创建客户端对象bean
    @LoadBalanced // 开启Ribbon负载均衡
    public RestTemplate getRestTemplate(){
        //普通spring内置客户端
        //return new RestTemplate();

        //Okhttp3类型的客户端创建
        return new RestTemplate(new OkHttp3ClientHttpRequestFactory());
    }*/
}